// 全局类型定义导出

// DICOM 相关类型
export * from './dicom.types';

// 通用工具类型
export type Nullable<T> = T | null;
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export type DeepPartial<T> = {
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
};

// 异步类型
export type PromiseResult<T, E = Error> = Promise<{ success: true; data: T } | { success: false; error: E }>;

// 事件类型
export interface EventHandler<T = any> {
  (event: T): void;
}

// 配置类型
export interface Configurable {
  configure(options: any): void;
  getConfig(): any;
}

// 可销毁类型
export interface Disposable {
  dispose(): void;
}

// 可初始化类型
export interface Initializable {
  initialize(): Promise<void>;
  isInitialized(): boolean;
}

// 可重置类型
export interface Resettable {
  reset(): void;
}

// 状态管理类型
export interface StateMachine<T extends string> {
  currentState: T;
  transitionTo(state: T): boolean;
  canTransitionTo(state: T): boolean;
}

// 进度类型
export interface Progress {
  current: number;
  total: number;
  percentage: number;
  message?: string;
}

// 错误类型
export interface AppError {
  code: string;
  message: string;
  details?: any;
  stack?: string;
  timestamp: number;
}

// 日志级别
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';

// 日志条目
export interface LogEntry {
  level: LogLevel;
  message: string;
  timestamp: number;
  data?: any;
  context?: string;
}

// 缓存类型
export interface CacheEntry<T> {
  value: T;
  timestamp: number;
  ttl?: number;
}

// 内存使用信息
export interface MemoryUsage {
  used: number;
  total: number;
  percentage: number;
  limit?: number;
}

// 性能指标
export interface PerformanceMetrics {
  startTime: number;
  endTime?: number;
  duration?: number;
  memoryUsage?: MemoryUsage;
  operations: number;
  errors: number;
}
